package conf

import (
	"gitee.com/llakcs/agile-go/log"
	gredis "gitee.com/llakcs/aglie-layout/data/redis"
	"github.com/redis/go-redis/v9"
)

type RedisConf struct {
	Addr     string `mapstructure:"addr"`
	Db       int    `mapstructure:"db"`
	Password string `mapstructure:"password"`
}

func LoadRedis(conf *RedisConf) {
	if conf.Addr == "" {
		//没有redis配置返回空
		log.Info("No Redis configuration information available")
		return
	}
	r := gredis.NewRedisClient(
		&redis.Options{
			Addr:     conf.Addr,
			DB:       conf.Db,
			Password: conf.Password})
	gredis.SetGlobalRedis(r)
	log.Info("Redis addr:", conf.Addr)
	log.Info("Redis component is initialized")
}
